﻿using ControllerLayer;
using DataAccessObjectLayer;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ModelLayer;

namespace UnitTest
{
    /// <summary>
    /// Summary description for UnitTestPerson
    /// </summary>
    [TestClass]
    public class UnitTestPerson
    {
        private readonly Customer _c;
        private readonly Customer _ac;

        /// <summary>
        /// Initializes a new instance of the <see cref="UnitTestPerson"/> class.
        /// </summary>
        public UnitTestPerson()
        {
            int id = GetMax.GetMaxId("SELECT MAX(id) FROM Person");
            _c = new Customer("Navn", "Adresse", 9000, "Aalborg", 12345678, "email", id, 100, CustomerStatusEnum.Active, "billinginfo");
            _ac = new Customer("Anders", "Adresse", 9000, "Aalborg", 12345678, "email", id, 100, CustomerStatusEnum.Active, "billinginfo");
        }

        /// <summary>
        /// Creates the customer.
        /// </summary>
        [TestMethod]
        public void CreateCustomer()
        {
            var pCtr = new PersonCtr();
            int i = pCtr.CreateCustomer(_c);
            Assert.AreNotEqual(i, -1);
        }

        /// <summary>
        /// Gets the customer.
        /// </summary>
        [TestMethod]
        public void GetCustomer()
        {
            var pCtr = new PersonCtr();
            long id = _c.Id;
            Customer c = pCtr.GetCustomer(id);

            Assert.AreEqual(_c.Id, c.Id);
        }

        /// <summary>
        /// Updates the customer.
        /// </summary>
        [TestMethod]
        public void UpdateCustomer()
        {
            var pCtr = new PersonCtr();
            int i = pCtr.UpdateCustomer(_ac);
            Assert.AreNotEqual(i, -1);
        }

        /// <summary>
        /// Deletes the customer.
        /// </summary>
        [TestMethod]
        public void DeleteCustomer()
        {
            var pCtr = new PersonCtr();
            int i = pCtr.DeleteCustomer(_c.Id);
            Assert.AreNotEqual(i, -1);
        }
    }
}